#pragma once

#include <iostream>
#include <limits> 
#include <climits> 

class BitUtility {
public:
    static int alignGreaterEqual(int v, int base) {
        if (v > base) {
            return ((v & (v-1)) == 0)?  v : 1 << bitWidth(v);
        } else {
            return base;
        }
    }

    static int bitWidth(unsigned int value) {
        if (value == 0) return 1; 
        return std::numeric_limits<unsigned int>::digits - __builtin_clz(value); 
    }
};
